unit FormSetCountWares;

interface

uses
    Windows,
    Messages,
    SysUtils,
    Variants,
    Classes,
    Graphics,
    Controls,
    Forms,
    Dialogs,
    StdCtrls,
    cxControls,
    cxContainer,
    cxEdit,
    cxTextEdit,
    cxMaskEdit,
    cxSpinEdit, cxGraphics, cxLookAndFeels, cxLookAndFeelPainters;

type
    TfrmSetCountWares = class(TForm)
        seCount: TcxSpinEdit;
        bClose: TButton;
        procedure bCloseClick(Sender: TObject);
        procedure FormKeyPress(Sender: TObject; var Key: Char);
        procedure seCountPropertiesChange(Sender: TObject);
    private
        { Private declarations }
        fHighLimit: double;
    public
        { Public declarations }
        constructor Create(AOwner: TComponent; aHighLimit: double; aValue: double = 1); reintroduce;
    end;

var
    frmSetCountWares: TfrmSetCountWares;

implementation

{$R *.dfm}

constructor TfrmSetCountWares.Create(AOwner: TComponent; aHighLimit: double; aValue: double = 1);
begin
    inherited Create(AOwner);
    fHighLimit := aHighLimit;
    if fHighLimit <> 0 then
        seCount.Value := fHighLimit
    else
        seCount.Value := aValue;
end;

procedure TfrmSetCountWares.bCloseClick(Sender: TObject);
begin
    Close;
end;

procedure TfrmSetCountWares.FormKeyPress(Sender: TObject; var Key: Char);
begin
    if (Key = #13) then bClose.Click;
end;

procedure TfrmSetCountWares.seCountPropertiesChange(Sender: TObject);
begin
    if fHighLimit <> 0 then
        if seCount.Value > fHighLimit then seCount.Value := fHighLimit;
    if seCount.Value < 0 then seCount.Value := 0;
end;

end.

